User blog:Bognix/Wikia's adventure with TypeScript
For the time being we are using TypeScript in our Mercury project. If you want to know what TypeScript is I recommend this article or official documentation. Long story short TypeScirpt is a typed superset of JavaScript which compiles to (readable) JavaScript. If you want to know more about Mercury here you can find small description or if you prefer to read code instead of articles here is the link to the github repo. TypeScript @Wikia What worked for us It's typed When there is 40+ developers working on one project it's hard to keep up with all the changes. Having types makes it easier to understand parts of code you didn't know exist. You can create interfaces for custom objects. It discourages anti patterns like passing object around and adding more and more properties to it. When given object has some defined interface TSLint would mark all properties that aren't supposed to be in it as incorrect errors. However TS is typed - not strongly typed. It allows people to take shortcuts and instead of having readable and understandable code with descriptive types you might end up with some TS/JS hybrid. But more about it in "What didn't work for us" section. If you are wondering what about external libraries? There are already created type definitions for popular libraries - here 'It compiles' Compilation adds another step in build process but in times of watchers and tools to automate tasks it's not so annoying. On the bright side it adds another check before pushing the change to make sure code is correct. TSlint works as a charm. Because TypeScript is a superset of JavaScript the result of the compilation which send to browser looks very similar to the original TS code (unlike the coffescript). It makes debugging sooo much easier. 'ES6' TypeScript has class definition (including class properties which are not supported in ES6), concise methods, arrow functions - so all the cool features of ES6. It's alive It's alive project with many contributors. New versions are released almost every month. It keeps up with newest trends in JavaScript (ES6 syntax). What didn't work for us 'It's typed' As I mentioned in the previous section types can make our lives so much easier. But only when they are used right. First off all the existence of type any, it's needed but it allows developers to take shortcuts. When you create new object or module you should create an interface for it. But it takes some time and there is this little thing called any and it's so tempting to use it. As time goes you end up with bunch of anys and only few interfaces. That's what happened in our case :( I mentioned DefinitelyTyped as a resource of typings for external libraries. In Wikia we are trying to stay up-to-date with JS frameworks we use so we try to update Ember as soon as possible. Sometimes definitielyTyped doesn't move forward as fast as we do and we add some typing on our own and out of the sudden we can't pull recent changes from DefinitelyTyped because we would burn in conflicts hell. Some typings from DefinitelyTyped are just not working for us - for instance Ember.$.Ajax. Our IDEs are constantly marking code as wrong even though there is nothing wrong with typing or code itself. Because of this "always red" situation people are getting more and more immune to red and are no longer paying attention when something is marked as incorrect in IDE. 'Ember + TypeScript' We are using Ember. Soon we would like to start using ember-cli so we can take advantage of all the goodies people create like ember addons. Unfortunately we can't do this when we use TS since all addons are written in ES6. Conclusion Right now we are moving away from TypeScript. We are migrating to ES6 + Babel combination. But don't get me wrong TypeScript is not a bad thing. It just didn't work for us. It's all about discipline and not taking shortcuts. It can be a blessing when it comes to code understandability and readability. Category:Blog posts